package worklog.dto;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.google.gson.Gson;

public class UserDTO {
	private int id;
	private String login;
	private String email;
	private String password;
	private int status;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public void set(ResultSet res) {
		try { setId(res.getInt("id")); } catch (SQLException e) { }
		try { setLogin(res.getString("login")); } catch (SQLException e) { }
		try { setEmail(res.getString("email")); } catch (SQLException e) { }
		try { setStatus(res.getInt("status")); } catch (SQLException e) { }
	}
	
	public void setAll(ResultSet res) {
		try { setId(res.getInt("id")); } catch (SQLException e) { }
		try { setLogin(res.getString("login")); } catch (SQLException e) { }
		try { setEmail(res.getString("email")); } catch (SQLException e) { }
		try { setPassword(res.getString("password")); } catch (SQLException e) { }	// security!
		try { setStatus(res.getInt("status")); } catch (SQLException e) { }
	}

	public String toString() {
		return new Gson().toJson(this);		
	}

}
